/*
 * Copyright (c) 2011-2014, fortiss GmbH.
 * Licensed under the Apache License, Version 2.0.
 *
 * Use, modification and distribution are subject to the terms specified
 * in the accompanying license file LICENSE.txt located at the root directory
 * of this software distribution. A copy is available at
 * http://chromosome.fortiss.org/.
 *
 * This file is part of CHROMOSOME.
 *
 * $Id: printSensorValueFunction.c 7805 2014-03-13 09:54:35Z geisinger $
 */

/**
 * \file
 *         Source file for function printSensorValue in component monitorKB.
 *
 * \author
 *         This file has been generated by the CHROMOSOME Modeling Tool (XMT)
 *         (fortiss GmbH).
 */

/******************************************************************************/
/***   Includes                                                             ***/
/******************************************************************************/
#include "sensorMonitor/adv/monitorKB/include/printSensorValueFunction.h"

#include "sensorMonitor/adv/monitorKB/include/printSensorValueFunctionWrapper.h"
#include "sensorMonitor/adv/monitorKB/include/monitorKBComponent.h"
#include "sensorMonitor/adv/monitorKB/include/monitorKBComponentWrapper.h"
#include "sensorMonitor/adv/monitorKB/include/monitorKBManifest.h"

#include "xme/core/logUtils.h"

#include "xme/hal/include/mem.h"

// PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_C_INCLUDES) ENABLED START
#include "xme/core/log.h"
#include <inttypes.h>
// PROTECTED REGION END

/******************************************************************************/
/***   Definitions                                                          ***/
/******************************************************************************/

// PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_C_DEFINITIONS) ENABLED START

// PROTECTED REGION END

/******************************************************************************/
/***   Variables                                                            ***/
/******************************************************************************/

// PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_C_VARIABLES) ENABLED START

// PROTECTED REGION END

/******************************************************************************/
/***   Prototypes                                                           ***/
/******************************************************************************/

// PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_C_PROTOTYPES) ENABLED START

// PROTECTED REGION END

/******************************************************************************/
/***   Implementation                                                       ***/
/******************************************************************************/
xme_status_t
sensorMonitor_adv_monitorKB_printSensorValueFunction_init
(
    sensorMonitor_adv_monitorKB_monitorKBComponent_config_t* const componentConfig
)
{
    // PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_INITIALIZE_C) ENABLED START
    
    XME_UNUSED_PARAMETER(componentConfig);
    
    return XME_STATUS_SUCCESS;
    
    // PROTECTED REGION END
}

void
sensorMonitor_adv_monitorKB_printSensorValueFunction_step
(
    sensorMonitor_adv_monitorKB_monitorKBComponent_config_t* const componentConfig
)
{
    xme_status_t status[1];
    
    sensorMonitor_topic_sensorData_t portSensorValueInData; // Required port.
    
    (void)xme_hal_mem_set(&portSensorValueInData, 0u, sizeof(sensorMonitor_topic_sensorData_t));
    
    status[0] = sensorMonitor_adv_monitorKB_monitorKBComponentWrapper_readPortSensorValueIn(&portSensorValueInData);
    
    {
        // PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_STEP_C) ENABLED START

        XME_UNUSED_PARAMETER(componentConfig);

        if (XME_STATUS_SUCCESS == status[0])
        {
            XME_LOG
            (
                XME_LOG_ALWAYS,
                "MonitorKB: Host %s reported that %s for %s is  %" PRIu64 " KB\n",
                portSensorValueInData.hostName, portSensorValueInData.sensorType,
                portSensorValueInData.sensorInstance, portSensorValueInData.sensorValue
            );
        }

        // PROTECTED REGION END
    }
    
    {
        // PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_STEP_2_C) ENABLED START
    
        // TODO: Auto-generated stub
        //       Check return values of writePort calls here
    
        // PROTECTED REGION END
    }
}

void
sensorMonitor_adv_monitorKB_printSensorValueFunction_fini
(
    sensorMonitor_adv_monitorKB_monitorKBComponent_config_t* const componentConfig
)
{
    // PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_TERMINATE_C) ENABLED START
    
    XME_UNUSED_PARAMETER(componentConfig);
    
    // PROTECTED REGION END
}

// PROTECTED REGION ID(SENSORMONITOR_ADV_MONITORKB_PRINTSENSORVALUEFUNCTION_IMPLEMENTATION_C) ENABLED START

// PROTECTED REGION END
